package bdcin.servlet.actions.dissertacao;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bdcin.classesbasicas.Area;
import bdcin.classesbasicas.Docente;
import bdcin.excecoes.BuscarException;
import bdcin.fachada.BDCInFactory;
import bdcin.fachada.IBDCIn;
import bdcin.servlet.actions.Action;

public class CarregarDadosDissertacao extends Action {

	@Override
	public void executar(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		IBDCIn facade = BDCInFactory.getFacade();
		List<Area> areas = null;
		List<Docente> docentes = null;
		
		try {
			areas = facade.listarAreas();
			docentes = facade.buscarDocentePorNome("");
		} catch (BuscarException e) {
			request.setAttribute("mensagem", e.getMessage());
			request.getRequestDispatcher("mensagem.jsp").forward(request, response);	
		}
		
		
		request.setAttribute("areas", areas);
		request.setAttribute("docentes", docentes);
		
		request.getRequestDispatcher("/dissertacao/cadastrarDissertacao.jsp").forward(request, response);
	}

}
